import type { RouterConfig } from '@nuxt/schema';
import routes from '~/pages/routes';

const addonRoutes: Record<string, any> = import.meta.glob('@/addons/**/routes.ts', { eager: true });

// 插件路由
for (const key in addonRoutes) {
    const addon = key.split('/')[2];
    routes.unshift(...addonRoutes[key].default.map((item) => {
        item.meta = item.meta ? Object.assign(item.meta, { addon }) : { addon };
        return item;
    }))
}

export default <RouterConfig>{
    routes: (_routes) => routes,
    strict: false
}